<?php

namespace app\admin\model;

use think\Model;

class PurchaseOrdersDetail extends BaseModel
{
    public function product()
    {
        return $this->belongsTo(Product::class, 'productid', 'id')->bind(['cname', 'code', 'id', 'style_code', 'unit', 'unit_sum']);
    }

    public function receipt()
    {
        return $this->hasMany(PurchaseReceiptDetails::class, 'purchase_orders_detail_id', 'detail_id')->bind(['entered_num' => 'number'])->where('is_del', 0)->withDefault(['number' => 0]);
    }

    public function order()
    {
        return $this->belongsTo(Order::class, 'order_id', 'id')->bind(['order_no' => 'order_no']);
    }

    public function getEntryNumAttr()
    {
        return 0;
    }
}
